<form method="post" id="frmAddr" name="frmAddr" action="{$smarty.const.HOST_VFRIEND}account/basicsave" enctype="multipart/form-data">
	<input type="hidden" name="phascode" id="phascode" value="" />
    <input type="hidden" name="ptsave" id="ptsave" value="{$intType}" />
	<div class="editForm">    	
        <div class="userInput">
        	<label>Quốc gia:</label>
        	<div class="pCountry">
            	<select class="select" id="pcountry" name="pcountry" onchange="javascript:province(this.value,'pprovince','secProvince','secDistrict')">
                	<option value="">Chọn</option>
                	{html_options options=$arrCountry selected=$objUser->country}
                </select>
            </div>	
        </div>
        <div class="userInput" id="secProvince">
        	<label>Tỉnh/thành:</label>
        	<div class="pProvince">
            	<select class="select" id="pprovince" name="pprovince" {if $objUser->province <=0}title="Chọn"{/if} onchange="javascript:district(this.value,'pdistrict','secDistrict')">
                	<option value="">Chọn</option>
                	{html_options options=$arrProvince selected=$objUser->province}
                </select>
            </div>	
        </div>
        <div class="userInput" id="secDistrict" {if !$arrDistrict}style="display:none"{/if}>
        	<label>Quận/huyện:</label>
        	<div class="pDistrict">
            	<select class="select" id="pdistrict" name="pdistrict" {if $objUser->district <=0}title="Chọn"{/if}>
                	<option value="">Chọn</option>
                    {if $objUser->district > 0}
                		{html_options options=$arrDistrict selected=$objUser->district}
                    {else}
                    	{html_options options=$arrDistrict}
                    {/if}
                </select>
            </div>		
        </div>
        <div class="userInput">
        	<label for="paddr">Nơi ở:</label>
        	<input type="text" value="{if $objUser->addr}{$objUser->addr|escape}{/if}" id="paddr" name="paddr" maxlength="150" class="text" />	
        </div>       
        <div class="userInput">
        	<input type="submit" value="Thay đổi" class="btnSubmit" />
            <input type="button" value="Hủy" class="btnCancel" onclick="javascript:basicClose('{$strView}','{$strEdit}')" />
        </div>
    </div>
</form>
<script type="text/javascript" language="javascript" src="{$smarty.const.HOST_STATICS}js/library/init.js"></script>
{literal}
<script type="text/javascript" language="javascript">
	$(document).ready(function(){
		$("#frmAddr").validate({				
			errorClass		: "errorMessage",
			errorElement	: "span",
			onfocusout		: false,
			onkeyup			: false,
			rules: {	
				pcountry:{
					required	: true
				},
				pprovince:{
					required	: true
				},
				pdistrict:{
					required	: true
				},
				paddr:{
					required	: true
				}
				
			},
			messages: {	
				pcountry:{
					required	: country_required
				},
				pprovince:{
					required	: province_required
				},
				pdistrict:{
					required	: district_required
				},
				paddr: {
					required	: addr_required
				}
			},		
			errorPlacement: function(label, element) {			
				var id = element.attr("id");
				if(id == "pdistrict") {
					label.insertAfter($(".pDistrict span.select"));			
				} else {			 
					label.insertAfter($("#" + id));			
				}
			},
			submitHandler: function(form) {				
				form.submit();
			}
		});	
		province = function(strCountry, divProvince, secProvince, secDistrict) {
			$.getJSON(
				HOST_VFRIEND + "ajax/province?country=" + strCountry + "&callback=?",		
				function(response) {				
					if(response["data"] != "") {	
						$("#"+secProvince).show();				
						$("#"+divProvince).html(response["data"]);
						
					}
					else {
						$("#"+secDistrict).hide();
						$("#"+secProvince).hide();
					}
				}
			);							   
		};	
		district = function(intProvince, divDistrict, secDistrict) {			
			$.getJSON(
				HOST_VFRIEND + "ajax/district?province=" + intProvince + "&callback=?",		
				function(response) {				
					if(response["data"] != "") {	
						$("#"+secDistrict).show();				
						$("#"+divDistrict).html(response["data"]);						
					}
					else {
						$("#"+secDistrict).hide();
					}
				}
			);							   
		};		
	});
</script>
{/literal}